/*
 * speaker.cpp for GodSpeaker
 *
 *
 * Author: healich@gmail.com
 */
#include <qtextedit.h>
#include <qpushbutton.h>
#include <qframe.h>
#include <qlayout.h>
#include "speaker.h"

Speaker::Speaker( QWidget *parent, const char *name, WFlags f )
    : QWidget( parent, name, f )
{
    //create widget
    msgText = new QTextEdit(this);
    msgText->setMinimumWidth(100);
    msgText->setMinimumHeight(100);

    delBtn = new QPushButton(tr("D"), this);
    clearBtn = new QPushButton(tr("C"), this);
    sendBtn = new QPushButton(tr("S"), this);
    connect(delBtn, SIGNAL(clicked()), this, SLOT(delOneChar()));
    connect(clearBtn, SIGNAL(clicked()), msgText, SLOT(clear()));
    connect(sendBtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
testBtn = new QPushButton(tr("Test"), this);
connect(testBtn, SIGNAL(clicked()), this, SLOT(testClick()));

    pickFrame = new QFrame(this);
    pickFrame->setMinimumWidth(100);
    pickFrame->setMinimumHeight(100);

    inputFrame = new QFrame(this);
    inputFrame->setMinimumWidth(100);
    inputFrame->setMinimumHeight(100);

    //put widgets in layout
    QHBoxLayout *hLayout1 = new QHBoxLayout;
    hLayout1->addWidget(delBtn);
    hLayout1->addWidget(clearBtn);
    hLayout1->addWidget(sendBtn);
hLayout1->addWidget(testBtn);
    hLayout1->addStretch(1);

    QHBoxLayout *hLayout2 = new QHBoxLayout;
    hLayout2->addWidget(pickFrame);
    hLayout2->addWidget(inputFrame);

    QVBoxLayout *vLayout = new QVBoxLayout(this);
    vLayout->addWidget(msgText);
    vLayout->addLayout(hLayout1);
    vLayout->addLayout(hLayout2);
}

Speaker::~Speaker()
{
}

void Speaker::delOneChar()
{
    msgText->del();
}

void Speaker::clearMsg()  //not used
{
    msgText->clear();
}

void Speaker::sendMsg()
{
    //todo:open com1 and send string and command
}

void Speaker::testClick()
{
    msgText->setText(QString::fromLatin1("Hello, how are you!"));
}
